package com.paipai.listen;

import java.util.HashMap;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import com.paipai.utils.AuthCodeServlet;
@Component
public class RabbitListen {
	 @RabbitListener(bindings = @QueueBinding(
	            value = @Queue(value = "paipai.sms.queue", durable = "true"),//队列
	            exchange = @Exchange(value = "paipai.sms.exchange",ignoreDeclarationExceptions = "true"),//管道
	            key = "sms.verify.code"))//路由键
	@RabbitHandler
	public void verifyCode(HashMap<String, String> map ) {
		 if(map==null||map.size()<1) {
			 return;
		 }
		 String random = map.get("random");
		 String phone = map.get("phone");
		 if( random==null||random.equals("")||phone==null||phone.equals("")) {
			 
			 return;
		 }
		 System.out.println("监听到消息了: "+map);
		 //向短信平台发送手机号码,验证码
		//AuthCodeServlet.AuthCodeVerify(phone,random);
		 
	}

}
